user {{ repo_service_user_name }} {{ repo_service_group_name }};
pid {{ repo_nginx_pid }};

worker_processes {{ repo_nginx_threads }};

events {
    worker_connections {{ repo_worker_connections }};
    multi_accept on;
}

http {
    # Basic Settings
    include /etc/nginx/mime.types;
    default_type application/octet-stream;
    sendfile off;
    tcp_nopush on;
    tcp_nodelay on;
    client_header_timeout 10m;
    client_body_timeout 10m;
    send_timeout 10m;
    proxy_read_timeout 600s;
    proxy_send_timeout 600s;
    proxy_connect_timeout 600s;

    # Added Larger Post Max
    client_max_body_size 5M;

    keepalive_timeout 60 15;
    types_hash_max_size 2048;

    # Logging Settings
    log_format gzip '$remote_addr - $remote_user [$time_local]  '
                    '"$request" $status $bytes_sent '
                    '"$http_referer" "$http_user_agent" "$gzip_ratio"';
    access_log /var/log/nginx/access.log gzip buffer=32k;
    error_log /var/log/nginx/error.log notice;

    # Gzip Settings
    gzip on;
    gzip_disable "msie6";
    gzip_vary on;
    gzip_proxied any;
    gzip_comp_level 6;
    gzip_min_length 1100;
    gzip_buffers 16 8k;

    # Turn on gzip for all content types that should benefit from it.
    gzip_types application/ecmascript;
    gzip_types application/javascript;
    gzip_types application/json;
    gzip_types application/pdf;
    gzip_types application/postscript;
    gzip_types application/x-javascript;
    gzip_types image/svg+xml;
    gzip_types text/css;
    gzip_types text/csv;

    # "gzip_types text/html" is assumed.
    gzip_types text/javascript;
    gzip_types text/plain;
    gzip_types text/xml;

    gzip_http_version 1.0;

    # Custom Header
    add_header X-WHOAMI "OpenStack Private Slushee Repository {{ inventory_hostname }}";

    # Virtual Host Configs
    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;

    # Map Mobile
    map $http_user_agent $is_mobile {
      default 0;
      ~*android|ip(hone|od)|windows\s+(?:ce|phone) 1;
      ~*symbian|sonyericsson|samsung|lg|blackberry 1;
      ~*mobile 1;
    }
}
